import { useEffect, useState } from "react";
import { getChannelAPI } from "@/apis/article";

// 获取频道所有的逻辑
function useChannel(params) {
  // 获取频道列表 getChannelAPI
  const [channelList, setChannelList] = useState([]);
  useEffect(() => {
    const getChannelList = async () => {
      const res = await getChannelAPI();
      setChannelList(res.data.channels);
    };
    //   调用函数
    getChannelList();
  }, []);
  // 把组件用到的数据return出去
  return { channelList };
}

export { useChannel };
